package cn.student.dao;

import cn.student.pojo.Work;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Mapper
@Repository
public interface WorkDaoMapper {

    /**
     * 插入作业数据
     *
     * @param work
     * @return
     */
    int insert(Work work);

    /**
     * 删除作业数据
     *
     * @param workId
     * @return
     */
    int delete(@Param("workId") long workId);


    /**
     * 查询所有作业
     *
     * @return
     */
    List<Work> select();


    /**
     * 根据作业id查询作业
     *
     * @param workId
     * @return
     */
    Work selectById(@RequestParam("workId") long workId);


    /**
     * 更新作业
     *
     * @param work
     * @return
     */
    int update(Work work);


    /**
     * 根据用户id和竞赛id查询下面的作业
     *
     * @param userId
     * @param cpId
     * @return
     */
    Work selectByUserId(@Param("userId") long userId, @Param("cpId") long cpId);

}
